package com.ojoin.trade.t0loan_core.web.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.utils.LogUtils;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.common.web.service.impl.BaseServiceImpl;
import com.ojoin.trade.t0loan_core.web.dao.TbT0PosTranscationOfLoanTransanctionDao;
import com.ojoin.trade.t0loan_core.web.domain.TbT0PosTranscationOfLoanTransanction;
import com.ojoin.trade.t0loan_core.web.service.T0PosTranscationOfLoanTransanctionBaseService;

/**
 * T+0贷款记录与pos机交易记录对照信息服务实现
 * @author guoting
 *
 */
@Service
public class T0PosTranscationOfLoanTransanctionBaseServiceImpl extends BaseServiceImpl<TbT0PosTranscationOfLoanTransanction> implements
		T0PosTranscationOfLoanTransanctionBaseService {

	@Autowired
	private TbT0PosTranscationOfLoanTransanctionDao dao;
	
	/**
	 * 新建九盈T+0贷款记录与pos机交易记录对照表记录(T0000012)
	 */
	@Override
	public int insertT0PosTranscationOfLoanTransanction(int t0loanTransLogId,
			String posTransLogId) throws BusinessException {
		LogUtils.getT0loanLog().info("新建九盈T+0贷款记录与pos机交易记录对照表记录. t0loanTransLogId->" + t0loanTransLogId + ", posTransLogId->" + posTransLogId);
		
		TbT0PosTranscationOfLoanTransanction contrastvo = new TbT0PosTranscationOfLoanTransanction();
		
		//contrastvo设值
		contrastvo.setIdOfTbT0LoanTransanctionLog(t0loanTransLogId);
		contrastvo.setPosTranscantionId(posTransLogId);
		
		this.getBaseDao().insert(contrastvo);
		return contrastvo.getId();
	}

	
	@Override
	protected BaseDao<TbT0PosTranscationOfLoanTransanction> getBaseDao() {
		return dao;
	}


	@Override
	public Integer queryT0PosTranscationCountByLoanTransanctionId(
			int t0loanTransLogId) throws BusinessException {
		LogUtils.getT0loanLog().info("查询九盈T+0贷款记录中包含的pos机交易记录集合. t0loanTransLogId->" + t0loanTransLogId);
		
		 return ((TbT0PosTranscationOfLoanTransanctionDao) this
				.getBaseDao()).queryT0PosTranscationCountByLoanTransanctionId(t0loanTransLogId);
	}


	@Override
	public void insertIntoT0PosTranscationOfLoanTransanction(Integer t0loanTransLogId, Integer joinuserid, String transdate)
			throws BusinessException {
		((TbT0PosTranscationOfLoanTransanctionDao) this
				.getBaseDao()).insertIntoT0PosTranscationOfLoanTransanction(t0loanTransLogId, joinuserid, transdate);
	}

}
